//==============================================================================
// REGRESSION FOR TABLE 5
//==============================================================================

clear all

* Load data  (multiple lines for subject; each line is a decision at start pos
  import delimited "./data/net-benefit-and-demographics.csv", encoding(ISO-8859-1) clear
  keep if next_action == 0 | next_action == 1  // Drop Invalid Data

* DV
  gen dv = next_action
	
* Convert Numeric
  replace sex = "" if sex == "NA"
  destring sex, replace
  
  replace edu = "" if edu == "NA"
  destring edu, replace
  
  replace econ = "" if econ == "NA"
  destring econ, replace
  
  replace stats = "" if stats == "NA"
  destring stats, replace
  
  replace stem = "" if stem == "NA"
  destring stem, replace
  
  replace biz = "" if biz == "NA"
  destring biz, replace
  
  replace expert = "" if expert == "NA"
  destring expert, replace
  
  destring config, replace force
	
* Covariates
  gen college     = 0
  replace college = 1 if edu >= 2  
  gen bizecon     = 0
  replace bizecon = econ + biz
  gen netbenefit2 = netbenefit * netbenefit

* Losses
  gen losses = 0
  replace losses = 1 if config == 3
  replace losses = 1 if config == 6
  replace losses = 1 if config == 12
  
* Labels
  label var losses      "Losses"
  label var moves_taken "Moves"
  label var sex         "Sex" 
  label var age         "Age"
  label var college     "College"
  label var stats       "Statistics"
  label var econ        "Economics"
  label var biz         "Business"
  label var expert      "Exposure"
  label var bizecon     "Biz Econ"

* LOGIT MODELS (reporting odds-ratio) 
  logistic dv losses , or cluster(eid)
  outreg2 using  "./results/06_net_benefit_table_5.xls", addstat("Log likelihood",  `e(ll)') alpha(0.001,0.01,0.05) symbol(***, **, *) bdec(4) label excel eform

  logistic dv losses netbenefit , or cluster(eid)
  outreg2 using  "./results/06_net_benefit_table_5.xls", addstat("Log likelihood",  `e(ll)') alpha(0.001,0.01,0.05) symbol(***, **, *) bdec(4) label excel eform
  
  logistic dv losses netbenefit moves_taken , or cluster(eid)
  outreg2 using  "./results/06_net_benefit_table_5.xls", addstat("Log likelihood",  `e(ll)') alpha(0.001,0.01,0.05) symbol(***, **, *) bdec(4) label excel eform
  
  logistic dv losses netbenefit moves_taken sex age college stats bizecon , or cluster(eid)
  outreg2 using  "./results/06_net_benefit_table_5.xls", addstat("Log likelihood",  `e(ll)') alpha(0.001,0.01,0.05) symbol(***, **, *) bdec(4) label excel eform
